package com.quasar.hpatient.Jpush;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

import com.quasar.hpatient.R;
import com.quasar.hpatient.model.litePalmodel.MedicationInfoDatadb;
import com.quasar.hpatient.utils.TimeZoneUtil;

import org.litepal.crud.DataSupport;

import java.util.Date;
import java.util.List;

/**
 * author : 许建宏
 * Date: 2017/12/28 0028
 * View:
 */

public class NotificationUtils {

    static int id=0;
    public static void NotificationManger(Context context, Intent intent){
        String Time=TimeZoneUtil.sdf.format(new Date()).substring(10, 16);
//        List<MedicationInfoDatadb> medicationInfoDatadbs= DataSupport.findAll(MedicationInfoDatadb.class);
//        int size=medicationInfoDatadbs.size();
//        for(int i=0;i<size;i++){
//
//            if(medicationInfoDatadbs.get(i).getUseTime()){
//
//            }
//        }


        try {
            int icon = R.mipmap.ic_logos;
            long when = System.currentTimeMillis();
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

            StringBuffer buffer=new StringBuffer();
            buffer.append("您好,服用时间到了，请服用:他克莫司 3*10粒");

            builder.setAutoCancel(true)
                    .setDefaults(Notification.DEFAULT_ALL)
                    .setWhen(System.currentTimeMillis())
                    .setSmallIcon(icon)
                    .setTicker("Hearty365")
                    .setContentTitle("吃药提醒")
                    .setContentText("记得吃药哦")
                    .setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_SOUND)
                    .setContentIntent(contentIntent);
//                    .setContentInfo("Info");
            NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.notify(id, builder.build());
            id++;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
